﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Validation;
using JXT.PrimaryKey.Batman.Collections;
using JXT.PrimaryKey.Batman.Domain.Models;
using JXT.PrimaryKey.Batman.Domain.Services;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Models;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Repositories;

namespace JXT.PrimaryKey.Batman.Domain.UserSystem.Services.Default
{
    public class AuthenticationLogService : ServiceBase<AuthenticationLog>, IAuthenticationLogService
    {
        public void Add(string title, string content)
        {
            Add(new AuthenticationLog() { Title = title, Content = content });
        }

        public void Add(AuthenticationLog entity)
        {
            if (entity == null)
                throw new ArgumentNullException("entity");
            entity.PostTime = DateTime.Now;
            LoadRepository<IAuthenticationLogRepository>().Add(entity);
        }

        public IPagedCollection<AuthenticationLog> GetList(IPagedSpecification<AuthenticationLog> specification)
        {
            if (specification == null)
                throw new ArgumentNullException("specification");
            return LoadRepository<IAuthenticationLogRepository>().GetList(specification);
        }
    }
}
